/*
 * Copyright (c) 2011 Samuel Ventura All Rights Reserved
 */
package dev2net;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author samuel
 */
class MmThread extends Thread {

    private final SharedState sharedState;

    public MmThread(SharedState sharedState) {
        this.sharedState = sharedState;
        this.setDaemon(true);
        this.setName("mmt");
    }

    @Override
    public void run() {
        Util.out("thread start");
        while(true) {
            //TODO is this copy access enough?
            Map<String, MmuConfig> map = new HashMap(sharedState.mmuConfigs);
            for(MmuConfig mmuConfig : map.values()) {
                try {
                    mmuConfig.sync();
                } catch (IOException ex) {
                    continue; //just continue to next iounit
                }
            }
        }
    }
}
